# -*- coding: utf-8 -*-
import sys
import mistune
from PySide import QtGui
from PySide import QtCore


class Window(QtGui.QWidget):
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
        self.markdown = mistune.Markdown()

        split = QtGui.QSplitter(self)
        self.left = QtGui.QTextEdit(split)
        self.right = QtGui.QTextEdit(split)

        self.left.textChanged.connect(self.convert)

        layout = QtGui.QHBoxLayout()
        layout.addWidget(split)
        self.setLayout(layout)

    def convert(self):
        text = self.left.toPlainText()
        html_text = self.markdown(text)
        self.right.setText(html_text)

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    widget = Window()
    widget.showMaximized()
    sys.exit(app.exec_())
